
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author Weton Li
 * @Date 2021/3/15 18:40
 */
public class 按位与翻转 {

    public int method(int a, int b, int c) {

        // 定义结果集result
        int result = 0;
        // 判断是否进行翻转处理
        while (a != 0 && b != 0 && c != 0) {
            int aa = a & 1;
            int bb = b & 1;
            int cc = c & 1;
            a = a >> 1; // 缩小1倍
            b = b >> 1;
            c = c >> 1;
            if ((aa | bb) == cc) {
                continue; // 退出当次循环，但不能退出整个while循环，继续向下遍历
            }
            if (cc == 1) { // 如果需要翻转
                result = result + 1;
            } else { // else如果不需要翻转
                if (aa == 1) {
                    result = result + 1;
                }
                if (bb == 1) {
                    result = result + 1;
                }
            }
        }
        // 返回结果集result
        return result;

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int nGroup = scanner.nextInt();
//        System.out.println("共有nGroup组数据"+nGroup);

        ArrayList<Integer> list = new ArrayList<>();

        按位与翻转 按位与翻转1 = new 按位与翻转();
        for (int i = 0; i < nGroup; i++) {
             int a = scanner.nextInt();
             int b = scanner.nextInt();
             int c = scanner.nextInt();
            int method = 按位与翻转1.method(a, b, c);
            list.add(method);
        }
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }
}
